const express = require('express')
const app = express()

// 设置ejs模板引擎
app.set('view engine','ejs');
 
app.get('/', function (req, res) {
  const info = {
    name: "jsthin",
    age: 27
  }
  const flag = true;
  const list = [
    {name: "jsthin"},
    {name: "dell"},
    {name: "lee"}
  ]
  res.render("index", {
    title: "ejs模板隐藏参数",
    info,
    flag,
    list
  })
})

// post请求
app.post('/dologin', function (req, res) {
  res.send('执行登录')
})

// get传值
app.get('/product', function (req, res) {
  let query = req.query // 获取get传值
  res.send('get传值' + query.id)
})
 
app.listen(3000, () => {
  console.log('app is running...')
})